<template>
	<view class="car-list-com">
		<view class="list-item">
			<view class="item">
				<view class="title">车架号：</view>
				<view class="value">{{ item.vin }}</view>
			</view>
			<view class="item">
				<view class="title">车型：</view>
				<view class="value">{{ item.hpzl }}</view>
			</view>
		</view>
		<view class="list-item">
			<view class="item">
				<view class="title">车牌号：</view>
				<view class="value">{{ item.hphm }}</view>
			</view>
			<view class="item">
				<view class="title">里程表：</view>
				<view class="value">{{ item.lCb }}</view>
			</view>
		</view>
		<view class="list-item">
			<view class="item">
				<view class="title">检测：</view>
				<view class="value">{{ item.isJC ? '已结束' : '待检测' }}</view>
			</view>
			<view class="item">
				<view class="title">整备：</view>
				<view class="value">{{ item.isZb ? '已整备' : '待整备' }}</view>
			</view>
		</view>
		<view class="list-item">
			<view class="item">
				<view class="title">采购员：</view>
				<view class="value">{{ name }}</view>
			</view>
			<view class="item">
				<view class="title">采购时间：</view>
				<view class="value">{{ formatISODate(item.createTime) }}</view>
			</view>
		</view>



		<view class="delete" @click="deleteItem(item)">
			<uni-icons type="trash" size="16" color="#cccccc"></uni-icons>
		</view>

	</view>
</template>

<script>
import {
	formatISODateTime
} from '@/utils/index.js'
import {
	updateCarStatus
} from '@/api/app.js'
export default {
	props: {
		item: {
			type: Object,
			default: {}
		},
		name: {
			type: String,
			default: ""
		}
	},
	data() {
		return {}
	},
	methods: {

		formatISODate(time) {
			return formatISODateTime(time)
		},
		deleteItem(item) {
			uni.showModal({
				title: '提示',
				content: '确认要删除此数据吗？',
				success: async (res) => {
					if (res.confirm) {
						delete item.infoFiles
						delete item.vehiclePhotos
						item.isDel = true
						const resp = await updateCarStatus(item)
						uni.showToast({
							icon: 'none',
							title: '操作成功'
						})
						this.$emit('init')
					}
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.car-list-com {
	padding: 40rpx 20rpx 20rpx;
	background-color: #ffffff;
	border-radius: 13rpx;
	box-shadow: rgba(100, 100, 111, 0.2) 0px 7rpx 29rpx 0px;
	margin-bottom: 20rpx;
	position: relative;

	.delete {
		width: 20rpx;
		height: 20rpx;
		position: absolute;
		top: 0%;
		right: 20rpx;
	}

	.list-item {
		display: flex;
		align-items: center;
		justify-content: space-between;

		.item {
			flex: 1;
			text-align: start;
			display: flex;
			align-items: center;
			line-height: 40rpx;

			.title {
				font-size: 24rpx
			}

			.value {
				flex: 1;
				font-size: 24rpx;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}
	}
}
</style>